home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-30 | 6.4 KB | 171 lines | [TEXT/CWIE] |
- // ===========================================================================
- // LAGADefaultOutline.cp
- // ===========================================================================
- // “Apple Grayscale Appearance” compliant default button outline
- // Copyright © 1996 Chrisoft (Christophe ANDRES) All rights reserved.
- //
- // You may use this source code in any application (commercial, shareware, freeware,
- // postcardware, etc), but not remove this notice (no need to acknowledge the use of
- // this class in the about box)
- // You may not sell this source code in any form. This source code may be placed on
- // publicly accessable archive sites and source code disks. It may not be placed on
- // profit archive sites and source code disks without the permission of the author,
- // Christophe ANDRES.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- //
- // If you make any change or improvement on this class, please send the improved/changed
- // version to : chrisoft@calva.net or Christophe ANDRES
- // 20, rue Prosper Mérimée
- // 67100 STRASBOURG
- // FRANCE
- //
- // ===========================================================================
- // LAGADefaultOutline.h <- double-click + Command-D to see class declaration
- //
- // LAGADefaultOutline is my implementation of the “Apple Grayscale Appearance for System 7.5”
- // default button outline (used by LAGADialogBox)
- //
- // This class requires AGAColors.cp to be present in your project
- //
- // Version : 1.2
- //
- // Change History (most recent first, date in US form : mm/dd/yy):
- //
- // 06/30/96 ca Public release of version 1.2
- // 06/19/96 dj Dan Johnson <DANJ@CSI.compuserve.com>
- // Added call to StColorPenState::Normalize to avoid odd influence on our colors
- // 06/04/96 ca Increased version to 1.2
- // 05/15/96 ca Replaced HasAGAColors by PaneInColor (see note in AGAColors.h)
- // 05/11/96 ca Increased version to 1.1
- // Replaced UEnvironment::HasFeature(env_SupportsColor) with HasAGAColors
- // Added change history
- // 04/22/96 ca class made available by Christophe ANDRES <chrisoft@calva.net>
- // (version 1.0)
- //
- // To Do:
- //
-
- #include "LAGADefaultOutline.h"
- #include "AGAColors.h"
-
- char LAGADefaultOutline::mCorners[4][5][5] = {
- // topleft
- {
- { -1, -1, -1, 12, B },
- { -1, -1, B, 2, 2 },
- { -1, B, 2, 2, 5 },
- { 12, 2, 2, 2, 8 },
- { B, 2, 5, 8, -1 }
- },
- // topright
- {
- { B, 12, -1, -1, -1 },
- { 2, 3, B, -1, -1 },
- { 5, 5, 4, B, -1 },
- { 8, 5, 5, 7, 12 },
- { -1, 8, 5, 8, B }
- },
- // bottomleft
- {
- { B, 2, 5, 8, -1 },
- { 12, 3, 5, 5, 8 },
- { -1, B, 4, 5, 5 },
- { -1, -1, B, 7, 8 },
- { -1, -1, -1, 12, B }
- },
- // bottomright
- {
- { -1, 8, 5, 8, B },
- { 8, 5, 7, 8, 12 },
- { 5, 7, 8, B, -1 },
- { 8, 8, B, -1, -1 },
- { B, 12, -1, -1, -1 }
- }
- };
-
-
-
- LAGADefaultOutline::LAGADefaultOutline (LPane *inHostPane) : LDefaultOutline (inHostPane)
-
- {
- ResizeFrameBy(-2, -2, false);
- MoveBy(1, 1, true);
- }
-
- void LAGADefaultOutline::DrawSelf ()
-
- {
- StColorPenState outlineColor; // <06/19/96 dj>
- Rect frame;
- Boolean hasColor = ::PaneInColor(this); // <05/15/96 ca>
- Boolean bwOutline = !hasColor;
-
- outlineColor.Normalize(); // <06/19/96 dj>
- if (CalcLocalFrameRect(frame))
- {
- while(true)
- {
- ::MoveTo(frame.left + 3, frame.top);
- ::LineTo(frame.right - 4, frame.top);
- ::LineTo(frame.right - 1, frame.top + 3);
- ::LineTo(frame.right - 1, frame.bottom - 4);
- ::LineTo(frame.right - 4, frame.bottom - 1);
- ::LineTo(frame.left + 3, frame.bottom - 1);
- ::LineTo(frame.left, frame.bottom - 4);
- ::LineTo(frame.left, frame.top + 3);
- ::LineTo(frame.left + 3, frame.top);
- if (bwOutline)
- {
- ::InsetRect(&frame,1 ,1);
- bwOutline = false;
- }
- else
- break;
- }
-
- if (hasColor)
- {
- const RGBColor *col = gAGAColorArray;
- for (int i = 0; i < 5; i++)
- for (int j = 0; j < 5; j++)
- {
- if (mCorners[0][i][j] != -1)
- ::SetCPixel(frame.left + j, frame.top + i, &col[mCorners[0][i][j]]);
- if (mCorners[1][i][j] != -1)
- ::SetCPixel(frame.right - 5 + j, frame.top + i, &col[mCorners[1][i][j]]);
- if (mCorners[2][i][j] != -1)
- ::SetCPixel(frame.left + j, frame.bottom - 5 + i, &col[mCorners[2][i][j]]);
- if (mCorners[3][i][j] != -1)
- ::SetCPixel(frame.right - 5 + j, frame.bottom - 5 + i, &col[mCorners[3][i][j]]);
- }
-
- ::RGBForeColor(&gAGAColorArray[2]);
- ::MoveTo(frame.left + 1, frame.top + 5);
- ::LineTo(frame.left + 1, frame.bottom - 6);
- ::MoveTo(frame.left + 5, frame.top + 1);
- ::LineTo(frame.right - 6, frame.top + 1);
-
- ::RGBForeColor(&gAGAColorArray[5]);
- ::MoveTo(frame.left + 4, frame.top + 2);
- ::LineTo(frame.right - 5, frame.top + 2);
- ::LineTo(frame.right - 3, frame.top + 4);
- ::LineTo(frame.right - 3, frame.bottom - 5);
- ::LineTo(frame.right - 5, frame.bottom - 3);
- ::LineTo(frame.left + 4, frame.bottom - 3);
- ::LineTo(frame.left + 2, frame.bottom - 5);
- ::LineTo(frame.left + 2, frame.top + 4);
- ::LineTo(frame.left + 4, frame.top + 2);
-
- ::RGBForeColor(&gAGAColorArray[8]);
- ::MoveTo(frame.right - 2, frame.top + 5);
- ::LineTo(frame.right - 2, frame.bottom - 6);
- ::MoveTo(frame.left + 5, frame.bottom - 2);
- ::LineTo(frame.right - 6, frame.bottom - 2);
- }
- }
- }
-
-